module App::Controller
    class Login < Qt::Object
        def initialize(parent)
            super()

            @view = App::View::Login.new(parent)
            connect(@view.buttonbox, SIGNAL(:accepted), @view, SLOT(:accept))
            connect(@view.buttonbox, SIGNAL(:rejected), @view, SLOT(:reject))
        end

        def exec
            ret = @view.exec == @view.class.Accepted
            accept if ret
            #dispose # ???
            ret
        end

        private
        def accept
            $widget.model.tree.toggl.email = @view.email.text
            $widget.model.tree.toggl.password = @view.password.text
            $widget.model.store_login if @view.remember.checkState == Qt::Checked
        end

        def dispose
            @view.dispose
            super()
        end
    end
end
